package example.file;

import java.io.File;
import java.util.Date;

/**
 * Created by lenovo on 2016/11/4 0004.
 * File 类的 fileToChange.lastModified() 和 fileToChange setLastModified() 方法来修改文件最后的修改日期
 */
public class LastModify {
    public static void main(String[] args)
            throws Exception {
        File fileToChange = new File("D:/java.txt");
        boolean newFile = fileToChange.createNewFile();
        Date fileTime = new Date(fileToChange.lastModified());
        System.out.println(fileTime.toString());
        System.out.println(fileToChange.setLastModified(System.currentTimeMillis()));
        fileTime = new Date(fileToChange.lastModified());
        System.out.println(fileTime.toString());
    }
}
